﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pokusAjax.aspx.cs" Inherits="BSCMFF.Web.pokusAjax" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery-1.6.1.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
 <script type="text/javascript">
     $(document).ready(function () {
         $("#sayHelloButton").click(function (event) {
             $.ajax({
                 type: "POST",
                 url: "WebServices/SaveDataFromQuestionnaire.asmx/HelloToYou",
                 data: "{'name': '" + $('#name').val() + "'}",
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",
                 success: function (msg) {
                     AjaxSucceeded(msg);
                 },
                 error: AjaxFailed
             });
         });
     });
     function AjaxSucceeded(result) {
         alert(result.d);
     }
     function AjaxFailed(result) {
         alert(result.status + ' ' + result.statusText);
     } 
 </script> 


 <h1> Calling ASP.NET AJAX Web Services with jQuery </h1>
 Enter your name:
 <input id="name" />
 <br />
 <input id="sayHelloButton" value="Say Hello"
 type="button"  />
    </div>
    </form>
</body>
</html>
